﻿using System;
using System.Threading.Tasks;
using NetMicro.Cache.RedisProvider;

namespace NetMicro.Cache
{
    /// <summary>
    /// redis扩展方法 支持滑动过期
    /// </summary>
    public interface IRedisCacheExtend
    {
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="key">缓存Key</param>
        /// <param name="value">缓存Value</param>
        /// <param name="entry">缓存策略</param>
        /// <returns></returns>
        void Set<T>(string key, T value, CacheEntry entry);


        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="key">缓存Key</param>
        /// <param name="value">缓存Value</param>
        /// <param name="entry">缓存策略</param>
        /// <returns></returns>
        Task SetAsync<T>(string key, T value, CacheEntry entry);


        /// <summary>
        /// 获取值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>

        T GetAndRefresh<T>(string key);


        /// <summary>
        /// 获取值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<T> GetAndRefreshAsync<T>(string key);
       
    }
}
